package com.yuan.securitydemo.controller;

import com.yuan.securitydemo.pojo.User;
import com.yuan.securitydemo.securtiy.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
@Slf4j
public class IndexController {
    @GetMapping("/index")
    public String index(Model model) {
        String username = SecurityUtils.getCurrentUser().getUsername();
        model.addAttribute("username", username);
        log.debug("当前用户：" + username);
        return "index";
    }

    @GetMapping("/login")
    public String login(){

        return "login";
    }

    @GetMapping("/register")
    public String register(){
        return "register";
    }

    @GetMapping("/error")
    public String error(){
        return "error";
    }
}
